import React, { Component, useState, useRef } from "react";
import classNames from "classnames";
import "./index.css";
function Child(props) {
  return (
    <>
      <h1>child</h1>
      <p>接收的数据{props.msg}</p>
      <button onClick={() => props.onChange("子组件修改之后的值")}>修改</button>
    </>
  );
}
export default function Parent() {
  let [msg, setMsg] = useState("这是一段文字");
  let updateMsg = (msg) => {
    setMsg(msg);
  };
  return (
    <>
      <h1>子传父</h1>
      <Child msg={msg} onChange={updateMsg}></Child>
    </>
  );
}
